import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store'
Vue.use(VueRouter)

const routes = [
  {
    name: 'Index',
    path: '/index',
    component: () => import('@/views'),
    children: [
      {
        name: 'UserIndex',
        path: '/user',
        component: () => import('@/views/user')
      },
      {
        name: 'CategoryIndex',
        path: '/category',
        component: () => import('@/views/category')
      },
      {
        name: 'BrandList',
        path: '/brand',
        component: () => import('@/views/brand')
      },
	  {
	    name: 'Role',
	    path: '/role',
	    component: () => import('@/views/role')
	  },
	  {
	    name: 'userList',
	    path: '/role-user',
	    component: () => import('@/views/role/userList')
	  },
	  {
	    name: 'resourceList',
	    path: '/resource',
	    component: () => import('@/views/role/resourceList')
	  },
    ]
  },
  {
    name: 'Login',
    path: '/login',
    component: () => import('@/views/login')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to, from, next) => {
//   // 拿到token
//   const token = store.getters.GET_TOKEN
//   if (token || to.path === '/login') {
//     next()
//     return
//   }
//   next('/login')
// })
export default router
